package phoenix.web.test_suites.wildbuddies.critical;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import phoenix.core.base.TestSuiteBase;
import phoenix.core.data_models.UserProfileDataModel;
import phoenix.core.data_models.UserProfileDataModel.AboutMe;
import phoenix.core.data_models.UserProfileDataModel.LookingFor;
import phoenix.web.test_objects.*;

/**
 * Test suite - Critical tests
 */
public class SearchTS extends TestSuiteBase
{
	// Tests
	private final RegistrationTests registrationTests = new RegistrationTests(phoenix);
	private final BackendTests backendTests = new BackendTests(phoenix);
	private final FunnelTests funnelTests = new FunnelTests(phoenix);
	private final SearchTests searchTests = new SearchTests(phoenix);
	private final PaymentTests paymentTests = new PaymentTests(phoenix);

	@DataProvider
	public Object[][] registrationDataMale()
	{
		return registrationTests.dataProviders.registrationDataMale();
	}

	@DataProvider
	public Object[][] funnelData()
	{
		return funnelTests.dataProviders.funnelData();
	}

	@DataProvider
	public Object[][] searchFunnelData()
	{
		return searchTests.dataProviders.searchFunnelData();
	}

	@DataProvider
	public Object[][] searchData()
	{
		return searchTests.dataProviders.searchData();
	}

	@DataProvider
	public Object[][] searchProfileData()
	{
		return searchTests.dataProviders.searchProfileData();
	}

	@DataProvider
	public Object[][] paymentDataSuccess()
	{
		return paymentTests.dataProviders.paymentDataSuccess();
	}

	@Test(dataProvider = "registrationDataMale", groups = { "registration" }, priority = 1, enabled = true)
	public void registrationMaleTest(String p_userGender, String p_userEmail, String p_userPassword, String p_userBirthDay, String p_userBirthMonth,
		String p_userBirthYear)
	{
		registrationTests.registrationTest(p_userGender, p_userEmail, p_userPassword, p_userBirthDay, p_userBirthMonth, p_userBirthYear);
	}

	@Test(dependsOnMethods = { "registrationMaleTest" }, groups = { "registration" }, priority = 2, enabled = true)
	public void getUserDataTest()
	{
		backendTests.getUserDataTest(testUser().getEmail());
	}

	@Test(dependsOnMethods = { "getUserDataTest" }, groups = { "registration" }, priority = 4, enabled = true)
	public void confirmationMaleTest()
	{
		funnelTests.confirmationTest();
	}

	@Test(dependsOnGroups = { "registration" }, dataProvider = "funnelData", groups = { "funnel" }, priority = 5, enabled = true)
	public void funnelMaleTest(String p_screenName, LookingFor p_lookingForParams, AboutMe p_aboutMeParams)
	{
		funnelTests.funnelTest(p_screenName, p_lookingForParams, p_aboutMeParams);
	}

	@Test(dependsOnGroups = { "registration" }, groups = { "funnel" }, priority = 6, enabled = true)
	public void searchUsersInSearchTest()
	{
		searchTests.countUsersAtSearchTest();
	}

	@Test(dependsOnMethods = { "confirmationMaleTest" }, dataProvider = "searchFunnelData", groups = { "search" }, priority = 7, enabled = true)
	public void searchFunnelFreeTest(LookingFor p_lookingForParams)
	{
		searchTests.searchAtFunnelTest(p_lookingForParams);
	}

	@Test(dependsOnMethods = { "confirmationMaleTest" }, dataProvider = "searchData", groups = { "search" }, priority = 8, enabled = true)
	public void searchFreeTest(LookingFor p_lookingForParams)
	{
		searchTests.searchAtToolbarTest(p_lookingForParams);
	}

	// https://redmine.platformphoenix.com/issues/126641
	@Test(dependsOnMethods = { "confirmationMaleTest" }, dataProvider = "searchProfileData", groups = { "search" }, priority = 9, enabled = false)
	public void searchProfileFreeTest(LookingFor p_lookingForParams)
	{
		searchTests.searchAtProfileTest(p_lookingForParams);
	}

	@Test(dependsOnMethods = { "confirmationMaleTest" }, groups = { "male" }, priority = 10, dataProvider = "paymentDataSuccess",
		enabled = true)
	public void paymentPackageTest(UserProfileDataModel.PaymentDetails p_paymentDataParams, Boolean p_expectedResult)
	{
		paymentTests.paymentPackageTest(p_paymentDataParams, p_expectedResult);
	}

	@Test(dependsOnMethods = { "confirmationMaleTest" }, dataProvider = "searchData", groups = { "search" }, priority = 11, enabled = true)
	public void searchPaidTest(LookingFor p_lookingForParams)
	{
		searchTests.searchAtToolbarTest(p_lookingForParams);
	}
}